package commRedisRpc

import (
	"encoding/json"
	commRedisRpc "gitee.com/fierce_wolf/go-fox-edge-common/commRedisList"
	"time"
)

type redisListPersistServerRecordRequest struct {
	redisList commRedisRpc.RedisListService
}

func (e *redisListPersistServerRecordRequest) Pop(timeout time.Duration) (*TaskRespondVO, error) {
	mainKey := "fox-edge:list:persist:record:request"

	jsn, err := e.redisList.KBPop(mainKey, timeout)
	if err != nil {
		return nil, err
	}
	if jsn == "" {
		return nil, err
	}

	var vo TaskRespondVO
	err = json.Unmarshal([]byte(jsn), &vo)
	if err != nil {
		return nil, err
	}

	return &vo, nil
}
